﻿using UnityEngine;
using System.Collections;

public class PlayerAttributes : MonoBehaviour {
	
	public float food = 100.0f;
	public float maxFood = 100.0f;
	public float drink = 100.0f;
	public float maxDrink = 100.0f;
	public float energy = 100.0f;
	public float maxEnergy = 100.0f;
	
	public void AddFood(float f) {
		food += f;
		if (food < 0)
			food = 0;
		if (food > maxFood)
			food = maxFood;
	}
	
	public void AddDrink(float f) {
		drink += f;
		if (drink < 0)
			drink = 0;
		if (drink > maxDrink)
			drink = maxDrink;
	}
	
	public void AddEnergy(float f) {
		energy += f;
		if (energy < 0)
			energy = 0;
		if (energy > maxEnergy)
			energy = maxEnergy;
	}
	
	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
		//Decrease food/drink/energy over time
		float elapsed = Time.deltaTime;
		food -= elapsed;
		drink -= elapsed;
		energy -= elapsed;
	}
	
	void OnGUI () {
		Color c = GUI.color;
		GUILayoutOption glo = GUILayout.Width(33);
		GUILayout.BeginArea(new Rect(0, Screen.height - 30, 100, 200));
		GUILayout.BeginHorizontal();
		GUILayout.FlexibleSpace();
		GUI.color = Color.red;
		GUILayout.Label("" + (int)food,glo);
		GUILayout.FlexibleSpace();
		GUI.color = Color.blue;
		GUILayout.Label("" + (int)drink,glo);
		GUILayout.FlexibleSpace();
		GUI.color = Color.yellow;
		GUILayout.Label("" + (int)energy,glo);
		GUILayout.FlexibleSpace();
		GUILayout.EndHorizontal();
		GUILayout.EndArea();
		GUI.color = c;
	}
}
